package com.simple.datax.conn.impl;

/** 
 * @Title: Worker.java 
 * @Package com.simple.datax.conn.impl 
 * @Description: 工作线程.
 * @author Joe Jin 
 * @date 2013-1-10
 * @version V1.0 
 */
public class Worker extends Thread {

	private Runnable runnable;
	private SendThreadPool pool;
	public Worker(Runnable runnable, SendThreadPool pool) {
		this.pool = pool;
		this.runnable = runnable;
	}
	
	@Override
	public void run() {
		try {
			runnable.run();
		} finally {
			// 执行操作之后，通知线程池以减少active thread数量
			if (pool != null) {
				pool.returnObject(null);
			}
		}
	}
}
